<%@ page language="java" pageEncoding="UTF-8"%><!DOCTYPE html><%@ taglib uri="http://java.sun.com/jsp/jstl/core"
	prefix="c"%>
<html>
<head>
<title>个人中心 </title>
<jsp:include page="/head.jsp" />
<link rel="stylesheet" type="text/css" href="assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="assets/plugins/bootstrap-table/bootstrap-table.min.css"" />
<script src="assets/plugins/bootstrap-table/bootstrap-table.min.js" type="text/javascript" charset="utf-8"></script>
<script src="assets/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
	
	<div style="background-color: rgb(233, 236, 239);">
		<div class="container-md">
			<nav aria-label="breadcrumb">
				<ol class="breadcrumb">
					<li class="breadcrumb-item"><a href="./">首页</a></li>
					<li class="breadcrumb-item ">我的订单</li>
					<li class="breadcrumb-item active">待收货</li>
				</ol>
			</nav>
		</div>
	</div>
	<div class="container-md">
		<div class="row">
			<div class="col-sm-3 left-menu">
				<div class="card bg-primary">
					<div class="card-header text-white"><i class="fa fa-list mr-2"></i>个人中心</div>
					<div class="list-group">
						<a href="order-1.let" class="list-group-item list-group-item-action }">
							修改个人信息</a> 
						<a href="order-2.let" class="list-group-item list-group-item-action${param.action=='my-2'?' active':'' }">
							修改个人头像</a> 
						<a href="order-3.let" class="list-group-item list-group-item-action">
							修改登录密码</a>
						<a href="order-4.let" class="list-group-item list-group-item-action">
							收货地址管理</a> 
					</div>
				</div>
				<div class="card bg-primary mt-2">
					<div class="card-header text-white"><i class="fa fa-list mr-2"></i>我的订单</div>
					<div class="list-group">
						<a href="usercenter/order1.jsp" class="list-group-item list-group-item-action">
							待付款</a>
						<a href="usercenter/order2.jsp" class="list-group-item list-group-item-action">
							待发货</a>
						<a href="usercenter/order3.jsp" class="list-group-item list-group-item-actionactive">
							待收货</a>
						<a href="usercenter/order4.jsp" class="list-group-item list-group-item-action${param.action=='o-3'?' active':'' }">
							评价/完成</a>
						
					</div>
				</div>
				
				
			 </div>
			<div class="col-sm-9" style="border: solid rgba(0, 0, 0, 0.1) 1px; box-shadow:0 0 .3rem rgba(0, 0, 0, 0.3); border-radius:5px; padding: 10px; z-index:1;">
				
				
				
				<!--   主内容写这里！！！！  -->
				<table class="table table-hover">
				<thead>
					<tr>
						<th data-width="40" data-align="center" data-formatter="indexFormatter">#</th>
						<th data-field="orderTime">订单时间</th>
						<th data-field="orderMoney" data-formatter="moneyFormatter">订单金额</th>
						<th data-field="orderAddressName">收货人</th>
						<th data-field="orderAddressTel">收货电话</th>
						<th class="_0 _2 _3 _4" data-field="orderPayTime">支付时间</th>
						<th class="_0 _1" data-field="orderTrackingTime">发货时间</th>
						<th>签收</th>
						<th data-align="center" data-field="orderId" data-formatter="lookFormatter">查看</th>
				</thead>
					<tbody id="tobody">
						<c:if test="${empty orderList}">
							<tr>
								<h1>亲亲您还没有订单哦，快去购买东东吧</h1>
							</tr>
						</c:if>
						<c:if test="${not empty orderList }">
							<c:forEach items="${orderList }" var="item" varStatus="s">
								<tr>
									<td>${s.count }</td>
									<td>${item.mallOrderDate }</td>
									<td>${item.mallOrderCash }</td>
									<td>${item.mallOrderName }</td>
									<td>${item.mallOrderPhone }</td>
									<td>${item.mallOrderPayfortime }</td>
									<td>${item.mallOrderSendtime }</td>
									<th><a href="javascript:receieve('${item.mallOrderId }')">签收</a></th>
									<td><a
										href="userorderlook.let?mallOrderId=${item.mallOrderId }">查看</a></td>
								</tr>
							</c:forEach>
						</c:if>
					</tbody>
				</table>
				
			
			
			
			
			</div> 
		</div>
	</div> 
	<script type="text/javascript" src="usercenter/order.js"></script>

</body>
</html>
<script>
	
	function receieve(id){
		
		if(confirm("确定已经收到订单了吗")){
			
			//发送异步请求
			$.post(
					"receieve.let",
					{mallOrderId:id},
					function(data){
						if(data.code == 1){
							sys.toastr.warn(data.msg);
						}else if(data.code == 2){
							sys.toastr.warn(data.msg);
							var tobody = $("#tobody");
							tobody.empty();//删除子元素
						}else{
							sys.toastr.success(data.msg);
							var tobody = $("#tobody");
							tobody.empty();//删除子元素
							$.each(data.list,function(i,obj){
								var tr = "<tr><td>"+(i+1)+"</td><td>"+time(new Date(obj.mallOrderDate),new Array("年","月","日"))+"</td><td>"+obj.mallOrderCash+"</td><td>"+obj.mallOrderName+"</td><td>"+obj.mallOrderPhone+"</td><td>"+time(new Date(obj.mallOrderPayfortime),new Array("年","月","日"))+"</td><td>"+time(new Date(obj.mallOrderSendtime),new Array("年","月","日"))+"</td><th><a href='javascript:receieve('"+obj.mallOrderId+"')>签收</a></th><td><a href='userorderlook.let?mallOrderId="+obj.mallOrderId+"'>查看</a></td></tr>";
								tobody.append(tr);//添加元素
							})
						}
					},
					"json"
					)
		}
	}
	
	
	//日期格式转换
	
	function time(d, type) {

		if (typeof d == "object") {

			var timeStr = "";

			var l = arguments.length;

			if (l == 1) {

				timeStr = d.getFullYear() + "年" + addZero((d.getMonth() + 1)) + "月"
						+ addZero(d.getDate()) + "日 " + addZero(d.getHours()) + ":"
						+ addZero(d.getMinutes()) + ":" + addZero(d.getSeconds());

			} else if (l == 2) {

				if (typeof type == "object") {

					if (type.length == 1) {

						timeStr = d.getFullYear() + type[0]
								+ (d.getMonth() + 1) + type[0] + d.getDate()
								+ " " + d.getHours() + ":" + d.getMinutes()
								+ ":" + d.getSeconds();

					} else if (type.length == 3) {

						timeStr = d.getFullYear() + type[0]
								+ (d.getMonth() + 1) + type[1] + d.getDate()
								+ type[2] + " " + d.getHours() + ":"
								+ d.getMinutes() + ":" + d.getSeconds();

					} else {

						type = new Array("-");

						timeStr = d.getFullYear() + type[0]
								+ (d.getMonth() + 1) + type[0] + d.getDate()
								+ type[0] + " " + d.getHours() + ":"
								+ d.getMinutes() + ":" + d.getSeconds();

					}

				}

			}

			return timeStr;

		}

		return "";

	}
	
	//补零
	function addZero(n){
        return n < 10 ? '0' + 4 : '' + n;
    };
	
</script>
